var firstLaunch = $api.getStorage('firstLaunch');
var _configData = {};
//当前软件的最新版本
var lastVersion = '1.0.21';
//版本列表
var versionList = ['1.0.D', '1.0.1','1.0.2','1.0.3','1.0.4','1.0.5','1.0.6','1.0.7','1.0.8','1.0.9','1.0.10','1.0.11','1.0.12','1.0.13','1.0.14','1.0.15','1.0.16','1.0.17','1.0.18','1.0.19','1.0.20','1.0.21'];

if (1 != firstLaunch) {
    //首次安装默认参数设置在此
    _configData = {
        //common设置=========================================================
        keyboard: 0,
        daogou: 0,
        moling: 0,
        molingtype: 0,
        membAge: 1, //默认新增会员年龄判断开启
        //api_url: 'http://121.41.36.202/api/index.php?app_act=',
        //api_url: 'http://121.41.36.202/demo_api/index.php?app_act=index/route&api=',
        //api_url: 'http://121.41.36.202/lite_api/index.php?app_act=index/route&api=',
        //api_url: 'http://175.102.17.16:28080/efast365/api/web/index.php?app_act=',
        api_url: '',
        patch_url: 'http://121.41.36.202/patch/',
        checklist: ["001", "002", "003", "004"],
        commonpay_num: 11,
        //print设置============================================================
        tel: '000-0000000',
        addr: '上海市浦东新区峨山路77号金牛大厦北座301室',
        check: 0,
        is_syn: "0",
        frequency: "1",
        create_db: 0,
        language: "zh_cn",
        finished: '1', //0尚未结束营业，1结束
        start: '0', //0尚未开始营业，1开始
        zftd: 0,
        printData: {
            selectvalue: '',
            check: 1,
            usb: 0,
            addr: '',
            tel: '',
            bluetooth: '',
            web_site: ''
        },
        no_ticket_return: 1,
        xuanzhuan: 1,
        skuPriceSynch: {
            is_syn: "0",
            frequency: "1"
        },
        cashsetData: {
            cashNum: '',
            cashName: '',
            cashDate: '',
            remark: ''
        }, //收银台设置
        MemAgeData: {
            UpperAge: 88,
            LowerAge: 3
        }, //会员年龄设置
        //首次安装商户设置
        shanghu: '',
		shanghu_password: '',
        normal: {
            rebate: [1, 1],
            price: [0, 0],
            money: [0, 0]
        },
        cashierTime: '',
        //manage: {
        //  rebate: [0.8, 1.2],
        //  price: [-20, 20],
        //  money: [-200, 200]
        //},
        //managePass: '123456',
        //cashierDesk: 'noDesk'
        adminPass: "cf79ae6addba60ad018347359bd144d2",
        //版本设置==========================================================
        version: "", //当前软件的安装版本
        update_time: "2016-04-29 18:00"
    };
    $api.setStorage('configData', _configData);
    $api.setStorage('firstLaunch', 1);
}


_configData = $api.getStorage('configData');
if (_configData.version != lastVersion) {
    _configData.versionList = versionList;
    $api.setStorage('configData', _configData);
}
/*
//1.0.1版本升级处理  _configData.version == '1.0.D' && 
if (_configData.version != lastVersion) {
    //如果有configData变动写在这里
    _configData.currencylist = [];
    _configData.currency_foreign = '0';
    _configData.standard_coin = '000';
    _configData.old_order = {
        '001': 1,
        '002': 2,
        '003': 3,
        '004': 4,
        '005': 5,
        '006': 6,
        '007': 7,
        '008': 8,
        '009': 9,
        '010': 10,
        '011': 11,
        '012': 12,
        '013': 13,
        '014': 14,
        '015': 15,
        '016': 16,
        '017': 17,
        '018': 18,
        '019': 19,
        '020': 20,
        '021': 21,
        '022': 22,
        '023': 23,
		'024': 24,
        '025': 25,
        '101': 26,
        '103': 27,
		'026': 28  	//shouqianba add by liuwei 20170808
    };
    //外链配置
    _configData.outlink = [
        {'name':'','position':'1','url':'','status':0},
        {'name':'','position':'2','url':'','status':0},
        {'name':'','position':'3','url':'','status':0},
        {'name':'','position':'4','url':'','status':0}
    ];
    //自动上传未上传数据 默认关闭
    _configData.auto_load = 1;
    //自动上传未上传数据频率 30min
    _configData.load_frequency = 1800000;
    _configData.offline_receipt = false;
    _configData.offline_vip = false;
    _configData.searchMacthType = "match_tail";//match_head按首位模糊匹配  match_tail按尾号模糊匹配 match_any全模糊匹配
	_configData.shanghu_password =  '',
    //会员列表每页显示数量
    _configData.vip_list_num = 10;
    //会员购买记录显示数量
    _configData.buy_list_num = 5;
	//飞凡设备
    _configData.feifan={
        'switched': false,
        'feifan':0
    };
    _configData.lanya = 1;
    //收银的默认输入项：
    _configData.default_input = 0;
    //收银抹零规则
    _configData.molingRule = "moling_rule_sswr";//moling_rule_sswr:四舍五入, moling_rule_sw:舍位, moling_rule_jw:进位
    $api.setStorage('configData', _configData);
    //如果有数据表结构变动写在 install/YsPos.json文件内


}
*/
//1.0.10版本设置
var set_1010_configData = function (version) {
    //如果有configData变动写在这里
    _configData.currencylist = [];
    _configData.currency_foreign = '0';
    _configData.standard_coin = '000';
    _configData.old_order = {
        '001': 1,
        '002': 2,
        '003': 3,
        '004': 4,
        '005': 5,
        '006': 6,
        '007': 7,
        '008': 8,
        '009': 9,
        '010': 10,
        '011': 11,
        '012': 12,
        '013': 13,
        '014': 14,
        '015': 15,
        '016': 16,
        '017': 17,
        '018': 18,
        '019': 19,
        '020': 20,
        '021': 21,
        '022': 22,
        '023': 23,
        '024': 24,
        '025': 25,
        '101': 26,
        '103': 27,
        '026': 28  	//shouqianba add by liuwei 20170808
    };
    //外链配置
    _configData.outlink = [
        {'name':'','position':'1','url':'','status':0},
        {'name':'','position':'2','url':'','status':0},
        {'name':'','position':'3','url':'','status':0},
        {'name':'','position':'4','url':'','status':0}
    ];
    //自动上传未上传数据 默认关闭
    _configData.auto_load = 1;
    //自动上传未上传数据频率 30min
    _configData.load_frequency = 1800000;
    _configData.offline_receipt = false;
    _configData.offline_vip = false;
    _configData.searchMacthType = "match_tail";//match_head按首位模糊匹配  match_tail按尾号模糊匹配 match_any全模糊匹配
    _configData.shanghu_password =  '',
        //会员列表每页显示数量
        _configData.vip_list_num = 10;
    //会员购买记录显示数量
    _configData.buy_list_num = 5;
    //飞凡设备
    _configData.feifan={
        'switched': false,
        'feifan':0
    };
    _configData.lanya = 1;
    //收银的默认输入项：
    _configData.default_input = 0;
    //收银抹零规则
    _configData.molingRule = "moling_rule_sswr";//moling_rule_sswr:四舍五入, moling_rule_sw:舍位, moling_rule_jw:进位
    _configData.version = '1.0.10';
    $api.setStorage('configData', _configData);
    //如果有数据表结构变动写在 install/YsPos.json文件内

}
//设置版本号
var set_version = function(version){
    var _configData = $api.getStorage('configData');
    _configData.version = version;
    $api.setStorage('configData', _configData);
};
//1.0.11版本设置
var set_1011_configData = function(version){
    var _configData = $api.getStorage('configData');
    _configData.version = '1.0.11';
    $api.setStorage('configData', _configData);
};
//1.0.12版本设置
var set_1012_configData = function(version){
    var _configData = $api.getStorage('configData');
    _configData.version = '1.0.12';
    _configData.old_order = {
        '001': 1,
        '002': 2,
        '003': 3,
        '004': 4,
        '005': 5,
        '006': 6,
        '007': 7,
        '008': 8,
        '009': 9,
        '010': 10,
        '011': 11,
        '012': 12,
        '013': 13,
        '014': 14,
        '015': 15,
        '016': 16,
        '017': 17,
        '018': 18,
        '019': 19,
        '020': 20,
        '021': 21,
        '022': 22,
        '023': 23,
        '024': 24,
        '025': 25,
        '101': 26,
        '103': 27,
        '026': 28, //shouqianba add by liuwei 20170808
        '027': 29, //passport
		'028': 30, //shouqianba weixin
		'029': 31, //shouqianba zfb
    };
    //品牌对照表
    _configData.pass_port = {
        "LQX":"br_forestcabin",
    };


    $api.setStorage('configData', _configData);
};
//1.0.14版本设置
var set_1015_configData = function(version){
    var _configData = $api.getStorage('configData');
    _configData.version = '1.0.15';
    _configData.old_order = {
        '001': 1,
        '002': 2,
        '003': 3,
        '004': 4,
        '005': 5,
        '006': 6,
        '007': 7,
        '008': 8,
        '009': 9,
        '010': 10,
        '011': 11,
        '012': 12,
        '013': 13,
        '014': 14,
        '015': 15,
        '016': 16,
        '017': 17,
        '018': 18,
        '019': 19,
        '020': 20,
        '021': 21,
        '022': 22,
        '023': 23,
        '024': 24,
        '025': 25,
        '101': 26,
        '103': 27,
        '026': 28, //shouqianba add by liuwei 20170808
        '027': 29, //passport
        '028': 30, //shouqianba weixin
        '029': 31, //shouqianba zfb
    };
    $api.setStorage('configData', _configData);
};
//1.0.19版本设置
var set_1019_configData = function(version){
    var _configData = $api.getStorage('configData');
    _configData.version = '1.0.19';
    _configData.old_order = {
        '001': 1,
        '002': 2,
        '003': 3,
        '004': 4,
        '005': 5,
        '006': 6,
        '007': 7,
        '008': 8,
        '009': 9,
        '010': 10,
        '011': 11,
        '012': 12,
        '013': 13,
        '014': 14,
        '015': 15,
        '016': 16,
        '017': 17,
        '018': 18,
        '019': 19,
        '020': 20,
        '021': 21,
        '022': 22,
        '023': 23,
        '024': 24,
        '025': 25,
        '101': 26,
        '103': 27,
        '026': 28, //shouqianba add by liuwei 20170808
        '027': 29, //passport
        '028': 30, //shouqianba weixin
        '029': 31, //shouqianba zfb
		'030': 32, //JF37 云店交易
    };
    $api.setStorage('configData', _configData);
};

//1.0.21版本设置
var set_1021_configData = function(version){
    var _configData = $api.getStorage('configData');
    _configData.version = '1.0.21';
    _configData.old_order = {
        '001': 1,
        '002': 2,
        '003': 3,
        '004': 4,
        '005': 5,
        '006': 6,
        '007': 7,
        '008': 8,
        '009': 9,
        '010': 10,
        '011': 11,
        '012': 12,
        '013': 13,
        '014': 14,
        '015': 15,
        '016': 16,
        '017': 17,
        '018': 18,
        '019': 19,
        '020': 20,
        '021': 21,
        '022': 22,
        '023': 23,
        '024': 24,
        '025': 25,
        '101': 26,
        '103': 27,
        '026': 28, //shouqianba add by liuwei 20170808
        '027': 29, //passport
        '028': 30, //shouqianba weixin
        '029': 31, //shouqianba zfb
		'030': 32, //JF37 云店交易
		'031': 33, //招商银行APP
    };
    $api.setStorage('configData', _configData);
};

//版本配置信息
set_version_configData = function (version) {
    switch (version){
        case '1.0.1':
        case '1.0.2':
        case '1.0.3':
        case '1.0.4':
        case '1.0.5':
        case '1.0.6':
        case '1.0.7':
        case '1.0.8':
        case '1.0.9':
        {
            set_version(version);
            break;
        }
        case '1.0.10':{
            set_1010_configData(version);
            break;
        }
        case '1.0.11':{
            set_1011_configData(version);
            break;
        }
        case '1.0.12':{
            set_1012_configData(version);
            break;
        }
        case '1.0.13':{
            set_version(version);
            break;
        }
        case '1.0.14':{
            set_version(version);
            break;
        }
        case '1.0.15':{
            set_1015_configData(version);
            break;
        }
        case '1.0.16':{
            set_version(version);
            break;
        }
        case '1.0.17':{
            set_version(version);
            break;
        }
        case '1.0.18':{
            set_version(version);
            break;
        }
        case '1.0.19':{
            set_1019_configData(version);
            break;
        }
		case '1.0.20':{
            set_version(version);
            break;
        }
		case '1.0.21':{
            set_1021_configData(version);
            break;
        }
    }
}